#ifndef _UBT_STATE_TASK_CHARGE_H_
#define _UBT_STATE_TASK_CHARGE_H_
#include "ubt_state_types.h"
#include "ubt_interface/msg/charge_msg_v1.hpp"
#include "std_msgs/msg/u_int8.hpp"
#include "std_msgs/msg/string.hpp"

namespace ubt_state
{

enum ubt_task_charge_phase
{
    ubt_task_charge_phase_idle,
    ubt_task_charge_phase_enter,
    ubt_task_charge_phase_charge,
    ubt_task_charge_phase_leave
};


class CTaskCharge: public ITask
{
  public:
    static int ClassInit();
    static void ClassCleanup();
    static ITask *CreateTask(ITaskCb *pTaskCb, std::string taskId, geometry_msgs::msg::Pose2D poseDst, double dis, int index, int reportIndex, std::string chargeType, int chargeTime = -1);
    ~CTaskCharge();

    bool Init(ITaskCb *pTaskCb, std::string taskId, geometry_msgs::msg::Pose2D poseDst, double dis, int index, int reportIndex, std::string chargeType, int chargeTime);

    virtual bool Start();
    virtual void Pause();
    virtual void Continue();
    virtual void Stop(int reason);
    virtual void OnTimer();
    virtual void OnMsg(int msgType, void *pvMsg);

    virtual ubt_task_type GetType();
    virtual ubt_task_state GetState();
    virtual ubt_task_stage GetStage();
    virtual std::string GetActionType();
    virtual void GetIndex(int& index, int& reportIndex);
    virtual void GetStopInfo(int& stopReason, std::string& stopReasonDesc);
    virtual void GetLogs(std::vector<TaskLogItem>& logs);

    void Charge_Result_Callback(const ubt_interface::msg::ChargeMsgV1::SharedPtr msg);



  private:
    void _CheckPause(int event);
    void  SendChargeMsg(ubt_interface::msg::ChargeMsgV1& chargeMsg);
    ITaskCb *_pTaskCb;
    std::string _taskId;
    int _index;
    int _reportIndex;
    geometry_msgs::msg::Pose2D _poseDst;
    double _dis;

    ubt_task_state _state;
    int _msgId;
    ubt_task_charge_phase _chargePhase;
    long _phaseTime;

    int _avoidHwStatus;
    int _pauseState;

    int _stopReason;
    int _chargeTime;
    std::string _stopReasonDesc;
    std::string _chargeType;
};



}

#endif

